<!DOCTYPE html>


<html lang="zh-CN">


<head>
  <meta charset="utf-8" />
  <meta name="baidu-site-verification" content="code-kg5UjKJZM2" />
   
  <meta name="keywords" content="活,炼" />
   
  <meta name="description" content="shimmerjordan" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    GAMES101 Lec5-6 光栅化notes |  丛烨-shimmerjordan
  </title>
  <meta name="generator" content="hexo-theme-ayer">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/dist/main.css">

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">
  
<link rel="stylesheet" href="/css/custom.css">

  
  <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
  
  

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'G-Q0DT8B8VJW', 'auto');
ga('send', 'pageview');

</script>



  
<script>
var _hmt = _hmt || [];
(function() {
	var hm = document.createElement("script");
	hm.src = "https://hm.baidu.com/hm.js?6d06f826e125297d4ce0fa7a1449328e";
	var s = document.getElementsByTagName("script")[0]; 
	s.parentNode.insertBefore(hm, s);
})();
</script>


<link rel="alternate" href="/atom.xml" title="丛烨-shimmerjordan" type="application/atom+xml">
</head>

</html>

	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css">
	<script src="https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/autoload.js"></script>


<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-GAMES101-Lec5-6-光栅化"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  GAMES101 Lec5-6 光栅化notes
</h1>
 

    </header>
     
    <div class="article-meta">
      <a href="/2024/06/28/games101-lec5-6/" class="article-date">
  <time datetime="2024-06-28T05:41:34.000Z" itemprop="datePublished">2024-06-28</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%9B%BE%E5%BD%A2%E5%AD%A6/">图形学</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">1.5k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">5 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="After-MVP"><a href="#After-MVP" class="headerlink" title="After MVP"></a>After MVP</h1><blockquote>
<p>在做了MVP把物体转化为一个Canonical cube之后，我们需要做什么？<br>——将其投影到屏幕</p>
</blockquote>
<p>屏幕由像素点（可以暂时理解为一个小方块）构成，是离散的，二维的。像素由RGB的混合有了颜色</p>
<span id="more"></span>
<h2 id="Canonical-Cube"><a href="#Canonical-Cube" class="headerlink" title="Canonical Cube"></a>Canonical Cube</h2><p>先不考虑$z$的关联，需要通过<em>视口变换</em>将平面$\left[-1,\; 1\right]^2$转为$[0, weight] \times [0, height]$：$M_{viewport}=\left(\begin{array}{ccc} \frac{width}{2} &amp; 0 &amp; 0 &amp; \frac{width}{2} \\ 0 &amp; \frac{height}{2} &amp; 0 &amp; \frac{height}{2} \\ 0 &amp; 0 &amp; 1 &amp; 0\\ 0 &amp; 0 &amp; 0 &amp; 1 \end{array}\right)$，这样就可以在投影之后同时将左下角定义为$(0,\; 0)$</p>
<h1 id="光栅"><a href="#光栅" class="headerlink" title="光栅"></a>光栅</h1><h2 id="显示设备"><a href="#显示设备" class="headerlink" title="显示设备"></a>显示设备</h2><ul>
<li>示波器：通过偏移电子成像在感光平面；采用隔行扫描降低成像工作量，但容易出现画面撕裂</li>
<li>现代屏幕：将内存/显存的一部分区域显示到屏幕上</li>
<li>平板显示设备Flat Panel Displays：<ul>
<li>LCD：Liquid Crystal Display通过调整自身排布影响光极化（偏正方向）</li>
<li>LED、OLED等等</li>
<li>Electronic Ink Display</li>
</ul>
</li>
</ul>
<h1 id="光栅化"><a href="#光栅化" class="headerlink" title="光栅化"></a>光栅化</h1><h2 id="三角形"><a href="#三角形" class="headerlink" title="三角形"></a>三角形</h2><p>计算机生成图像中，最基本的二维元素是三角形，对其的离散化操作就是生成图像的重点。至于为什么选择三角形：</p>
<ul>
<li>最基础的多边形，其他多边形可以划分成三角形</li>
<li>必定在一个平面；内外区分分明；插值方便（定义其中一个点的属性之后可以根据到三边距离等确定其他位置点的 属性）</li>
</ul>
<p>我们需要将图像显示在屏幕上，例如下图我们怎么判断绿框中的位置的RGB（亮或不亮）呢：</p>
<p><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240529172003566.png" alt="cdn by https://gcore.jsdelivr.net"></p>
<h2 id="离散化-采样"><a href="#离散化-采样" class="headerlink" title="离散化-采样"></a>离散化-采样</h2><blockquote>
<p>这就是为了解决刚才提到的问题，确切的说是判断一个像素和三角形的位置关系 or 像素中心点和三角形的位置关系</p>
<h3 id="原理"><a href="#原理" class="headerlink" title="原理"></a>原理</h3><p>Sampling实质上是将一个函数离散化的过程：一个像素点对应一个坐标点，对这个坐标点采样，判断它在不在三角形里面。</p>
</blockquote>
<p><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240529175700443.png" alt="cdn by https://gcore.jsdelivr.net"></p>
<ul>
<li>可以采用上图的右图的蓝色包围盒的方式做光栅化的加速（不处理边界外的）</li>
<li>也可以用其他加速方法，例如左边的incremental triangle traversal（适用于窄长并且有旋转角度的，这样加速才明显）</li>
</ul>
<h1 id="Antialiase-反走样（抗锯齿）"><a href="#Antialiase-反走样（抗锯齿）" class="headerlink" title="Antialiase 反走样（抗锯齿）"></a>Antialiase 反走样（抗锯齿）</h1><ul>
<li>Sampling artifacts（统称为瑕疵）</li>
</ul>
<h2 id="采样的缺点："><a href="#采样的缺点：" class="headerlink" title="采样的缺点："></a>采样的缺点：</h2><ul>
<li>空间上Signals are changing too frequent (high frequency), but sampled too slowly<ul>
<li>Jaggies (Staircase Pattern)：an example of “aliasing” – a sampling error</li>
<li>Moiré Patterns in Imaging 摩尔纹</li>
</ul>
</li>
<li>时间上Signals are changing too fast (high frequency), but sampled too slowly<ul>
<li>Wagon Wheel Illusion (False Motion)：倒着转的轮子</li>
</ul>
</li>
</ul>
<blockquote>
<p>Artifacts 背后的原因：信号变化过快，采样速率跟不上</p>
<h2 id="Antialiased-Sampling"><a href="#Antialiased-Sampling" class="headerlink" title="Antialiased Sampling"></a>Antialiased Sampling</h2></blockquote>
<h3 id="先Filter后采样"><a href="#先Filter后采样" class="headerlink" title="先Filter后采样"></a>先Filter后采样</h3><ul>
<li>Filter包括诸如卷积的方法：Getting rid of certain frequency contents 滤波器<ul>
<li>Convolution (= Averaging) 卷积（可以看作一种低通滤波器）</li>
</ul>
</li>
</ul>
<p><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240530113650706.png" alt="cdn by https://gcore.jsdelivr.net"></p>
<h3 id="傅里叶变换"><a href="#傅里叶变换" class="headerlink" title="傅里叶变换"></a>傅里叶变换</h3><p><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240530115904028.png" alt="cdn by https://gcore.jsdelivr.net"></p>
<p>$f(x)=\frac{A}{2}+\frac{2A\cos(t\omega)}{\pi}- \frac{2A\cos(3t\omega)}{3\pi}+ \frac{2A\cos(5t\omega)}{5\pi}-\dots$<br>另外注意到$e^{ix}=\cos x +i \sin x$，可以得到以下结论（傅里叶及逆变换）：</p>
<p><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240530120445706.png" alt="cdn by https://gcore.jsdelivr.net"></p>
<p>这样就知道，任何一个函数都可以分解成不同频率函数的综合</p>
<h3 id="采样频率"><a href="#采样频率" class="headerlink" title="采样频率"></a>采样频率</h3><p><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240530121608262.png" alt="cdn by https://gcore.jsdelivr.net"></p>
<p>sampling 是在频域上 copy &amp; paste 波形</p>
<ul>
<li>Aliasing = Mixed Frequency Contents</li>
<li>采样率不够的 copy &amp; paste 导致波形会有重叠（不恰当但是恰到“不好”处的采样频率会在不同的函数中采样出相同的结果）</li>
</ul>
<h1 id="Reduce-Aliasing-Error"><a href="#Reduce-Aliasing-Error" class="headerlink" title="Reduce Aliasing Error"></a>Reduce Aliasing Error</h1><h2 id="Option-1-Increase-sampling-rate"><a href="#Option-1-Increase-sampling-rate" class="headerlink" title="Option 1: Increase sampling rate"></a>Option 1: Increase sampling rate</h2><ul>
<li>increasing the distance between replicas in the Fourier domain</li>
<li>Higher resolution displays, sensors, framebuffers</li>
<li>costly &amp; may need very high resolution</li>
</ul>
<h2 id="Option-2-Antialiasing"><a href="#Option-2-Antialiasing" class="headerlink" title="Option 2: Antialiasing"></a>Option 2: Antialiasing</h2><ul>
<li>Filtering out high frequencies before sampling</li>
<li>Antialiasing = Limiting, then repeating</li>
</ul>
<h3 id="Antialiased-Sampling：Pre-Filter-→-Sample"><a href="#Antialiased-Sampling：Pre-Filter-→-Sample" class="headerlink" title="Antialiased Sampling：Pre-Filter → Sample"></a>Antialiased Sampling：Pre-Filter → Sample</h3><blockquote>
<p>convolving = filtering = averaging</p>
</blockquote>
<ul>
<li>先采样后模糊（Filter）是不行的（波形重叠的情况下截断依然会有重叠）</li>
<li>时域下的卷积 = 频域下的乘积，时域下的乘积 = 频域下的卷积<br><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240530144755652.png" alt="cdn by https://gcore.jsdelivr.net"></li>
</ul>
<h3 id="Antialiasing-By-Supersampling-MSAA"><a href="#Antialiasing-By-Supersampling-MSAA" class="headerlink" title="Antialiasing By Supersampling (MSAA)"></a>Antialiasing By Supersampling (MSAA)</h3><p>最理想的状态：我们需要一个近似的方法完成反走样，但不实际真的从硬件上增加很多像素点/分辨率。这就是MSAA的存在动机</p>
<ul>
<li>近似方法</li>
<li>Monte-Carlo</li>
<li>像素的<strong>颜色值</strong>为负责的区域内取样多次颜色值的平均。<br><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240530151452898.png" alt="cdn by https://gcore.jsdelivr.net"></li>
</ul>
<h3 id="MSAA的缺陷"><a href="#MSAA的缺陷" class="headerlink" title="MSAA的缺陷"></a>MSAA的缺陷</h3><p>No free lunch!</p>
<ul>
<li>MSAA：每个像素多次采样，求平均。太浪费性能</li>
<li>优化：不使用均匀分布，采样<strong>复用</strong></li>
<li>怎样分布样本才能达到最好的覆盖效果：Blue Noise?</li>
</ul>
<h2 id="Antialiasing-Today"><a href="#Antialiasing-Today" class="headerlink" title="Antialiasing Today"></a>Antialiasing Today</h2><h3 id="Milestones：目前得到广泛应用"><a href="#Milestones：目前得到广泛应用" class="headerlink" title="Milestones：目前得到广泛应用"></a>Milestones：目前得到广泛应用</h3><ul>
<li>FXAA(Fast Approximate AA)：先获得有锯齿的图，再<strong>后处理</strong>去除锯齿（很快）<ul>
<li>找到边界，换成没有锯齿的边界，（图像匹配）非常快</li>
<li>方法和采样无关，采样虽然有误，但是这种方法可以弥补</li>
</ul>
</li>
<li>TAA (Tem’poral AA) ：时序信息，借助前面帧的信息<ul>
<li>最近刚刚兴起</li>
<li>静态场景，相邻两帧同一像素用不同的位置来sample</li>
<li>把MSAA的Sampling分布在时间上</li>
<li>运动情况下怎么办？</li>
</ul>
</li>
<li>Super resolution / super sampling 超分辨率<ul>
<li>From low resolution to high resolution</li>
<li>Essentially still “not enough samples” problem 类似抗锯齿</li>
<li>DLSS (Deep Learning Super Sampling) 猜</li>
</ul>
</li>
</ul>
<h1 id="Visibility-Occlusion"><a href="#Visibility-Occlusion" class="headerlink" title="Visibility / Occlusion"></a>Visibility / Occlusion</h1><h2 id="深度缓存-Z-buffer"><a href="#深度缓存-Z-buffer" class="headerlink" title="深度缓存 Z-buffer"></a>深度缓存 Z-buffer</h2><p><strong>Painter’s Algorithm</strong>：由远及近画画，覆盖。（油画是这样的思路）</p>
<ul>
<li>深度计算与排序：$O(nlogn)$</li>
<li>可能有无法排序的情况：例如三个三角形互相重叠<br><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240530165233467.png" alt="cdn by https://gcore.jsdelivr.net"></li>
</ul>
<p><strong>因此引入Z-buffer</strong>：对每个像素多存一个深度<br><img src="https://gcore.jsdelivr.net/gh/shimmerjordan/pic_bed@obsidian-assets/Lec5-6-%E5%85%89%E6%A0%85%E5%8C%96/image-20240530165630546.png" alt="cdn by https://gcore.jsdelivr.net"></p>
<ul>
<li>实际coding中，(smaller z -&gt; further, larger z -&gt; closer)<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> (each triangle T)</span><br><span class="line">	<span class="keyword">for</span> (each <span class="built_in">sample</span> (x, y, z) in T)</span><br><span class="line">		<span class="keyword">if</span> (z &lt; zbuffer[x, y])            <span class="comment">// closest sample so far</span></span><br><span class="line">			framebuffer[x, y] = rgb;      <span class="comment">// update color</span></span><br><span class="line">			zbuffer[x, y] = z;            <span class="comment">// update depth</span></span><br><span class="line">		<span class="keyword">else</span></span><br><span class="line">			;             <span class="comment">// do nothing, this sample is occluded</span></span><br></pre></td></tr></table></figure></li>
<li>复杂度：$O(n)$ for n triangles —&gt; 并不是排序，而是只要<strong>最值</strong></li>
<li>需要保证三角形进入顺序和结果无关</li>
<li>无法处理透明物体</li>
</ul>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=https://blog.shimmerjordan.eu.org/2024/06/28/games101-lec5-6/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/GAMES101/" rel="tag">GAMES101</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%B8%B2%E6%9F%93/" rel="tag">渲染</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2024/06/28/games101-lec7-9/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            GAMES101 Lec7-9 Shading notes
          
        </div>
      </a>
    
    
      <a href="/2024/06/28/games101-lec3-4/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">GAMES101 Lec3-4 基础变换notes</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "StYfTMDp78X0EltFR16ve2q5-gzGzoHsz",
    app_key: "G4RPxRpXG6RwdfpnJefOSnyy",
    path: window.location.pathname,
    avatar: "wavatar",
    placeholder: "ヾﾉ≧∀≦)o来啊，快活啊!",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
   
   
<!-- minivaline评论 -->
<div id="mvcomments-box">
  <div id="mvcomments"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/minivaline@latest"></script>
<script>
    new MiniValine(Object.assign({"enable":true,"mode":"DesertsP","placeholder":"Write a Comment","math":true,"md":true,"enableQQ":true,"NoRecordIP":false,"visitor":true,"maxNest":6,"pageSize":6,"adminEmailMd5":"de8a7aa53d07e6b6bceb45c64027763d","tagMeta":["管理员","小伙伴","访客"],"master":["de8a7aa53d07e6b6bceb45c64027763d"],"friends":["b5bd5d836c7a0091aa8473e79ed4c25e","adb7d1cd192658a55c0ad22a3309cecf","3ce1e6c77b4910f1871106cb30dc62b0","cfce8dc43725cc14ffcd9fb4892d5bfc"],"lang":null,"emoticonUrl":["https://cdn.jsdelivr.net/npm/alus@latest","https://cdn.jsdelivr.net/gh/MiniValine/qq@latest","https://cdn.jsdelivr.net/gh/MiniValine/Bilibilis@latest","https://cdn.jsdelivr.net/gh/MiniValine/tieba@latest","https://cdn.jsdelivr.net/gh/MiniValine/twemoji@latest","https://cdn.jsdelivr.net/gh/MiniValine/weibo@latest"]}, {
	  el: '#mvcomments',
    }));
  const infoEle = document.querySelector('#mvcomments .info');
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
      infoEle.childNodes.forEach(function (item) {
          item.parentNode.removeChild(item);
      });
  }
</script>
<style>
	#mvcomments-box {
		padding: 5px 30px;
	}
	@media screen and (max-width: 800px) {
		#mvcomments-box {
		  padding: 5px 0px;
		}
	}
	.darkmode .MiniValine *{
		color: #f1f1f1!important;
	}
	.darkmode .commentTrigger{
		background-color: #403e3e !important;
	  }
	.darkmode .MiniValine .vpage .more{
		background: #21232F
	}
	.darkmode img{
		filter: brightness(30%)
	}
	.darkmode .MiniValine .vlist .vcard .vcomment-body .text-wrapper .vcomment.expand:before{
		background: linear-gradient(180deg, rgba(246,246,246,0), rgba(0,0,0,0.9))
	}
	.darkmode .MiniValine .vlist .vcard .vcomment-body .text-wrapper .vcomment.expand:after{
		background: rgba(0,0,0,0.9)
	}
	.darkmode .MiniValine .vlist .vcard .vcomment-body .text-wrapper .vcomment pre{
		background: #282c34
		border: 1px solid #282c34
	}
	.darkmode .MiniValine .vinputs-area .textarea-wrapper textarea{
		color: #000;
	}
	.darkmode .MiniValine .vinputs-area .auth-section .input-wrapper input{
		color: #000;
	}
	.darkmode .MiniValine .vinputs-area .vextra-area .vsmile-icons{
		background: transparent;
	}
	.darkmode .MiniValine .vinputs-wrap{
		border-color: #b2b2b5;
	}
	.darkmode .MiniValine .vinputs-wrap:hover{
		border: 1px dashed #2196f3;
	}
	.darkmode .MiniValine .vinputs-area .auth-section .input-wrapper{
		border-bottom: 1px dashed #b2b2b5;
	}
	.darkmode .MiniValine .vinputs-area .auth-section .input-wrapper:hover{
		border-bottom: 1px dashed #2196f3;
	}
	.darkmode .MiniValine .vbtn{
		background-color: transparent!important;
	}
	.darkmode .MiniValine .vbtn:hover{
		border: 1px dashed #2196f3;
	}
</style>

    
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2019-2024
        <i class="ri-heart-fill heart_icon"></i> 鞠桥丹-QIAODAN JU
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        由 <a href="https://hexo.io" target="_blank">Hexo</a> 强力驱动
        <span class="division">|</span>
        主题 - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s4.cnzz.com/z_stat.php?id=1279035150&amp;web_id=1279035150'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="丛烨-shimmerjordan"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">Home</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">Catalogue</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">Tags</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags/%E9%9A%8F%E7%AC%94/">Essay</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">Archives</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">Friends</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2020/01/18/about">About</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯蓝莓汁吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="/images/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="/images/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->


<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>

<!-- MathJax -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>

<!-- Katex -->

<!-- busuanzi  -->


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<!-- ClickLove -->


<script src="/js/clickLove.js"></script>


<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->


<link rel="stylesheet" href="/css/clipboard.css">

<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>


<!-- CanvasBackground -->


<script src="/js/dz.js"></script>



    
  </div>
</body>

</html>